<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>非受控组件</title>

</head>
<body>
<div id="test"></div>
</body>
<script src="../js/react.development.js"></script>
<script src="../js/react-dom.development.js"></script>
<!--将jsx转为js-->
<script src="../js/babel.min.js"></script>
<script src="../js/prop-types.js"></script>
<!--babel  由babel转换jsx-->
<script type="text/babel">
    // 页面中输入类的dom，现用现取值为非受控组件
    class Login extends React.Component {
        myRef = React.createRef()
        myRefBlur = React.createRef()
        showData = (e) => {
            e.preventDefault()
            alert('用户名：' + this.myRef.current.value + '密码：' + this.myRefBlur.current.value)
        }

        render() {
            return (
                <form onSubmit={this.showData}>
                    用户名：<input ref={this.myRef} name='username' type="text" placeholder="用户名"/>&nbsp;
                    密码：<input ref={this.myRefBlur} name='password' type="password" placeholder="密码"/>&nbsp;
                    <button>登录</button>
                </form>
            )
        }
    }

    ReactDOM.render(<Login/>, document.getElementById('test'))
</script>
</html>